<?php
if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}
/**
 * Description of products
 *
 * @author khanhdoan
 */
require APPPATH . '/libraries/REST_Controller.php';

class Imagess_api extends REST_Controller {

    function __construct() {
        parent::__construct();
        $this->load->model("images_m");
    }
    
    
    
    public function getImagesByProductId() {
        $args = array('id');
        //Lấy tham số POST vào Arr
        $args = $this->_parse_post_args($args);
        //Validation
        $rules = array(
            array(
                'field' => 'id',
                'label' => 'Id',
                'rules' => 'required|is_natural_no_zero'
            )
        );
        $this->form_validation->set_rules($rules);
        if ($this->form_validation->run() == TRUE) {
            $products = $this->products_m->get($args['id']);
            $this->response(array('status' => true, 'data' => $products), 200);
        } else {
            $this->response(array('status' => false, 'error' => validation_errors()), 400);
        }
        
    }

    public function getAll() {
        $products = $this->products_m->getAllProduct();
        $this->response(array('status' => true, 'data' => $products), 200);
    }

}
